<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Trackers - AIL</title>
    <link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png') }}">

    <!-- Core CSS -->
    <link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
    <link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
    <link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">

    <script src="{{ url_for('static', filename='js/jquery.js') }}"></script>
    <script src="{{ url_for('static', filename='js/helper.js')}}"></script>
    <script src="{{ url_for('static', filename='js/popper.min.js')}}"></script>
    <script src="{{ url_for('static', filename='js/bootstrap4.min.js') }}"></script>
{#    <script src="{{ url_for('static', filename='js/d3.min.js') }}"></script>#}
{#    <script src="{{ url_for('static', filename='js/d3/sparklines.js') }}"></script>#}

</head>
<body>

{% include 'nav_bar.html' %}

<div class="container-fluid">
    <div class="row">

        {% include 'hunter/menu_sidebar.html' %}

        <div class="col-12 col-lg-10" id="core_content">

                <div class="d-flex justify-content-around my-2">
                    <a class="btn btn-info  border-secondary" style="width: 20rem;" href="{{ url_for('hunters.tracked_menu') }}">
                        <div class="card-body">
                            <h5 class="card-title"><i class="fas fa-ruler-combined"></i>
                                All Trackers&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-light">{{ stats['all'] }}</span>
                            </h5>
                        </div>
                    </a>
                    <a class="btn btn-info  border-secondary" style="width: 20rem;" href="{{ url_for('hunters.tracked_menu_word') }}">
                        <div class="card-body">
                            <h5 class="card-title"><i class="fas fa-font"></i>
                                Words&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-light">{{ stats['word'] }}</span>
                            </h5>
                        </div>
                    </a>
                    <a class="btn btn-info  border-secondary" style="width: 20rem;" href="{{ url_for('hunters.tracked_menu_set') }}">
                        <div class="card-body">
                            <h5 class="card-title"><i class="fas fa-layer-group"></i>
                                Set&nbsp;&nbsp;&nbsp;&nbsp;<span class="badge badge-light">{{ stats['set'] }}</span>
                            </h5>
                        </div>
                    </a>
                </div>

                <div class="d-flex justify-content-around my-2">
                    <a class="btn btn-info  border-secondary" style="width: 20rem;" href="{{ url_for('hunters.tracked_menu_regex') }}">
                        <div class="card-body">
                            <h5 class="card-title">
                                <i class="fas fa-drafting-compass"></i>
                                Regex&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="badge badge-light">{{ stats['regex'] }}</span>
                            </h5>
                        </div>
                    </a>
                    <a class="btn btn-info  border-secondary" style="width: 20rem;" href="{{ url_for('hunters.tracked_menu_typosquatting') }}">
                        <div class="card-body">
                            <h5 class="card-title">
                                <i class="fa fa-clone"></i>
                                Typo Squatting&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="badge badge-light">{{ stats['typosquatting'] }}</span>
                            </h5>
                        </div>
                    </a>
                    <a class="btn btn-info  border-secondary" style="width: 20rem;" href="{{ url_for('hunters.tracked_menu_yara') }}">
                        <div class="card-body">
                            <h5 class="card-title">
                                <span class="bg-danger text-white font-weight-bold" style="font-size: 120%">&nbsp;{ </span>
                                Yara&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="badge badge-light">{{ stats['yara'] }}</span>
                            </h5>
                        </div>
                    </a>
                </div>

        {# TODO Buttons#}

            <a class="btn btn-primary my-2" href="{{ url_for('hunters.add_tracked_menu') }}">
                <i class="fas fa-plus-circle ml-auto"></i>
                Create New Tracker
            </a>

            <div class="card my-3">
                <div class="card-header bg-dark text-white">
                    <h5 class="card-title"><b>Trackers Last Matches</b></h5>
                </div>
                <div class="card-body">

                    <table class="table">
                        <thead>
                            <tr>
                                <th><i class="fa-solid fa-crosshairs"></i></th>
                                <th>tracker</th>
                                <th class="text-center"><i class="fas fa-cube"></i></th>
                                <th>Time</th>
                            </tr>
                        </thead>
                        <tbody id="tracked_objs">
                            {% for tracker in trackers %}
                                <tr>
                                    <td>{{ tracker['type'] }}</td>
                                    <td style="word-break: break-all;">
                                        <a href="{{ url_for('hunters.show_tracker') }}?uuid={{ tracker['uuid'] }}">{% if tracker['description'] %}{{ tracker['description'] }}{% else %}{{ tracker['tracked'] }}{% endif %}</a>
                                    </td>
                                    <td class="text-center">
                                        <a href="{{ tracker['obj']['link'] }}" onmouseenter="show_obj_tooltip(this, '{{ tracker['obj']['gid'] }}')" onmouseleave="hide_obj_tooltip(this)">
                                            <svg height="26" width="26" style="pointer-events:none;">
                                            <g class="nodes">
                                                <circle cx="13" cy="13" r="13" fill="{{ tracker['obj']['icon']['color'] }}"></circle>
                                                <text x="13" y="13" text-anchor="middle" dominant-baseline="central" class="{{ tracker['obj']['icon']['style'] }}" font-size="16px">{{ tracker['obj']['icon']['icon'] }}</text>
                                            </g>
                                        </svg>
                                        </a>
                                    </td>
                                    <td>{{ tracker['timestamp'] }}</td>
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>

                </div>
            </div>


        </div>
    </div>
</div>

<script>
    $(document).ready(function () {
        $("#page-Tracker").addClass("active");
        $("#nav_tracker_{{tracker_type}}").addClass("active");

{#        {% for dict_uuid in global_trackers %}#}
{#            sparkline("sparklines_{{ dict_uuid['uuid'] }}", {{ dict_uuid['sparkline'] }}, {height: 40});#}
{#        {% endfor %}#}

    });

    var url_obj_description = "{{ url_for('correlation.get_description') }}?object_id=";

    function toggle_sidebar() {
        if ($('#nav_menu').is(':visible')) {
            $('#nav_menu').hide();
            $('#side_menu').removeClass('border-right')
            $('#side_menu').removeClass('col-lg-2')
            $('#core_content').removeClass('col-lg-10')
        } else {
            $('#nav_menu').show();
            $('#side_menu').addClass('border-right')
            $('#side_menu').addClass('col-lg-2')
            $('#core_content').addClass('col-lg-10')
        }
    }
</script>

</body>
</html>
